<%--
  Created by cofey on 16/12/1.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>登录 - 无线南山统一管理平台</title>
    <meta charset="UTF-8"/>
    <link rel="stylesheet" type="text/css" href="${assets}/css/reset.css">
    <link rel="stylesheet" type="text/css" href="${assets}/css/structure.css">
</head>

<body>
<form class="box login">
    <fieldset class="boxBody">
        <label>用户</label>
        <input type="text" tabindex="1" name="loginUser" placeholder="用户名称" required>
        <label>密码</label>
        <input type="password" name="password" tabindex="2" required>
    </fieldset>
    <footer>
        <input type="button" class="btnLogin" value="登录" tabindex="3" onclick="config.login();">
    </footer>
</form>
<script type="text/javascript">
    var config = null;
    jQuery(function ($) {
        config = {
            login: function () {
                var loginUser = $(".login").find("input[name=loginUser]").val();
                var password = $(".login").find("input[name=password]").val();
                if (loginUser == '' || loginUser.length < 1) {
                    layer.msg("请输入用户");
                    return;
                }
                if (password == '' || loginUser.length < 1) {
                    layer.msg("请输入密码");
                    return;
                }
                $.post("${ctx}/login", {loginUser: loginUser, password: password}, function (res) {
                    if (res.errorCode > 0) {
                        layer.msg(res.errorMessage);
                    } else {
                        window.location.href = "${ctx}/index";
                    }
                });
            }
        };
        $(".login").find("input[name=password]").bind('keypress', function (event) {
            if (event.keyCode == "13") {
                config.login();
            }
        });
    });
</script>
</body>
</html>
